<?php
defined('InNcPHP') or exit('Access Invalid!');

/**
 * 广告轮播图
 * Class advertModel
 */
class advertModel extends Model{

    public static $advert_type = array(1=>'轮播',2=>'美食');

    public function __construct(){
        parent::__construct('advert');
    }

    /**
     * 广告列表分页
     * @param array $condition
     * @param string $field
     * @param int $page
     * @param string $order
     * @return mixed
     */
    public function getAdvertListPage($condition = array(), $field = '*', $page = 0, $order = 'advert_id desc '){
        return $this->field($field)->where($condition)->page($page)->order($order)->select();
    }

    /**
     * 获取广告图列表
     * @param array $condition
     * @param string $field
     * @param string $order
     * @return mixed
     */
    public function getAdvertList($condition = array(), $field = '*', $order = 'advert_id desc '){
        return $this->field($field)->where($condition)->order($order)->select();
    }

    /**
     * 获取一条广告图
     * @param array $condition
     * @param string $field
     * @return mixed
     */
    public function getAdvertInfo($condition = array(), $field = '*'){
        return $this->field($field)->where($condition)->find();
    }

    /**
     * 添加
     * @param array $param
     * @return mixed
     */
    public function addAdvert($param){
        return $this->insert($param);
    }

    /**
     * 更新
     * @param array $condition
     * @param array $param
     * @return mixed
     */
    public function updateAdvert($condition, $param){
        return $this->where($condition)->update($param);
    }

    /**
     * 伤处
     * @param array $condition
     * @return mixed
     */
    public function delAdvert($condition){
        return $this->where($condition)->delete();
    }
}
